/*
 * @Author: your name
 * @Date: 2020-08-12 20:56:03
 * @LastEditTime: 2020-08-12 21:09:22
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \day01\traning\test05\main.go
 */
package main

import (
	"fmt"
	"time"
)

// 获取当前时间，格式化输出为2017/06/19 20:30:05`格式。
// 编写程序统计一段代码的执行耗时时间，单位精确到微秒。

func timeStart(f func() int) {
	now := time.Now().Nanosecond()
	f()
	r := time.Now().Nanosecond() - now
	fmt.Println(r)
}

func main() {
	now := time.Now()
	fmt.Println(now.Format("2006/01/02 15:04:05"))

	// 定义函数
	add := func() int {
		return 1 + 3
	}
	timeStart(add)
}
